home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / share / 17 / dings_e.exe / Compiler / Bin / DXSound.h < prev    next >
C/C++ Source or Header  |  2001-02-22  |  2KB  |  76 lines

  1. #ifndef SFXSOUND_H
  2. #define SFXSOUND_H
  3.  
  4.  
  5. #ifndef RELEASE
  6.  #define RELEASE(x) if(x != NULL) { x->Release(); x = NULL; }
  7. #endif
  8.  
  9. #include "stdafx.h"
  10. #include "DSound.h" //Link To DXGuid.lib, DSound.lib
  11. #include "stdio.h"
  12. #include "mmsystem.h"
  13.  
  14. //////////////////////////////////////////////////////////////////////////////////
  15. // SFXSound Class
  16. //////////////////////////////////////////////////////////////////////////////////
  17. class SFXSound
  18. {
  19. public:
  20.     SFXSound(void);
  21.     ~SFXSound(void);
  22.  
  23.     BOOL Create(HWND hwnd);
  24.     BOOL GetCaps(void);
  25.     
  26.     LPDIRECTSOUND m_lpDS;
  27.     DSCAPS m_DSCaps;
  28. };
  29.  
  30. //////////////////////////////////////////////////////////////////////////////////
  31. // SFXSoundBuffer Class
  32. //////////////////////////////////////////////////////////////////////////////////
  33. class SFXSoundBuffer
  34. {
  35. public:
  36.     SFXSoundBuffer(void);
  37.     ~SFXSoundBuffer(void);
  38.  
  39.     BOOL Load(SFXSound* pDS, const char* Filename, int Num);
  40.     BOOL Play(int Pan = 0, DWORD dwFlags = 0);
  41.     BOOL Stop(void);
  42.     void SetVolume(LONG Volume);
  43.  
  44. private:
  45.     BOOL LoadFromFile(void);
  46.     BOOL CreateSoundBuffer(DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample,
  47.                                                  DWORD dwBlkAlign, BOOL bStereo);
  48.     BOOL ReadData(FILE* fp, DWORD dwSize, DWORD dwPos);
  49.     LPDIRECTSOUNDBUFFER GetFreeBuffer(void);
  50.  
  51. private:
  52.     int m_nBuffers;
  53.     int m_Current;
  54.     const char* m_Filename;
  55.     SFXSound* m_pDS;
  56.     LPDIRECTSOUNDBUFFER m_lpDSB[4];
  57. };
  58.  
  59. struct Waveheader
  60. {
  61.     BYTE        RIFF[4];          // "RIFF"
  62.     DWORD       dwSize;           // Size of data to follow
  63.     BYTE        WAVE[4];          // "WAVE"
  64.     BYTE        fmt_[4];          // "fmt "
  65.     DWORD       dw16;             // 16
  66.     WORD        wOne_0;           // 1
  67.     WORD        wChnls;           // Number of Channels
  68.     DWORD       dwSRate;          // Sample Rate
  69.     DWORD       BytesPerSec;      // Sample Rate
  70.     WORD        wBlkAlign;        // 1
  71.     WORD        BitsPerSample;    // Sample size
  72.     BYTE        DATA[4];          // "DATA"
  73.     DWORD       dwDSize;          // Number of Samples
  74. };
  75.  
  76. #endif